package com.ee.chat.api.controller;

import com.ee.chat.api.service.IPayNotifyService;
import com.ee.chat.common.bean.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;

/**
 * @author shane
 * @version 1.0.0
 * @Date 2021/1/26 15:49
 */
@RestController
@RequestMapping("payNotify")
public class PayNotifyController {
    private Logger log = LoggerFactory.getLogger(PayNotifyController.class);

    @Resource
    IPayNotifyService payNotifyService;

    /**
     * 微信支付回调
     * @Author Shane
     * @Date 2019/10/5 5:31
     * @param
     * @return
     */
    @RequestMapping("wxPayNotify")
    public String wxPayNotify(HttpServletRequest request){
        try {
            return payNotifyService.wxPayNotify(request);
        } catch(Exception e){
            log.error("【微信支付回调错误】", e);
        }
        return null;
    }

    /**
     * 支付宝支付回调
     * @Author Shane
     * @Date 2019/10/5 5:31
     * @param
     * @return
     */
    @RequestMapping("aliPayNotify")
    public String aliPayNotify(HttpServletRequest request){
        try {
            return payNotifyService.aliPayNotify(request);
        } catch(Exception e){
            log.error("【支付宝支付回调错误】", e);
        }
        return null;
    }

    /**
     * 苹果内购回调
     * @Author Shane
     * @Date 2019/12/23 15:43
     * @param receipt   支付收据
     * @param orderNumber   订单号
     * @return
     **/
    @RequestMapping("applePayNotify")
    public Result applePayNotify(@RequestParam String token, @RequestParam String receipt, @RequestParam String orderNumber){
        try {
            return payNotifyService.applePayNotify(token, receipt, orderNumber);
        } catch(Exception e){
            log.error("【苹果内购支付回调错误】", e);
            return Result.returnFailure();
        }
    }

    /**
     * 支付派支付回调
     * @Author Shane
     * @Date 2019/12/23 15:43
     * @return
     **/
    @RequestMapping("zfpaiPayNotify")
    public String zfpaiPayNotify(HttpServletRequest request){
        try {
            return payNotifyService.zfpaiPayNotify(request);
        } catch(Exception e){
            log.error("【支付派支付回调错误】", e);
        }
        return null;
    }

    /**
     * 云支付支付回调
     * @Author Shane
     * @Date 2019/12/23 15:43
     * @return
     **/
    @RequestMapping("yfkPayNotify")
    public String yfkPayNotify(HttpServletRequest request){
        try {
            return payNotifyService.yfkPayNotify(request);
        } catch(Exception e){
            log.error("【云支付支付回调错误】", e);
        }
        return null;
    }

    /**
     * 尊付支付回调
     * @Author Shane
     * @Date 2019/12/23 15:43
     * @return
     **/
    @RequestMapping("zunPayNotify")
    public String zunPayNotify(HttpServletRequest request){
        try {
            return payNotifyService.zunPayNotify(request);
        } catch(Exception e){
            log.error("【尊付支付回调错误】", e);
        }
        return null;
    }

    /**
     * 96支付回调
     * @Author Shane
     * @Date 2019/12/23 15:43
     * @return
     **/
    @RequestMapping("pay96Notify")
    public String pay96Notify(HttpServletRequest request){
        try {
            return payNotifyService.pay96Notify(request);
        } catch(Exception e){
            log.error("【96支付回调错误】", e);
        }
        return null;
    }

    /**
     * 付易来支付回调
     * @Author Shane
     * @Date 2019/12/23 15:43
     * @return
     **/
    @RequestMapping("fylPayNotify")
    public String fylPayNotify(HttpServletRequest request){
        try {
            return payNotifyService.fylPayNotify(request);
        } catch(Exception e){
            log.error("【付易来支付回调错误】", e);
        }
        return null;
    }
}
